<script lang="ts" setup>
import {login, getUsers} from '@/api'
import {ElLoading} from 'element-plus'


//加载配置
let loadingInstance: any,
    requestNum: number = 0,
    loading: boolean = true;

//加载动画
const addLoading = () => {
  // 防止重复弹出
  requestNum++;
  if (requestNum == 1) {
    loadingInstance = ElLoading.service({fullscreen: true});
  }
}

// 关闭 加载动画
const cancelLoading = () => {
  requestNum--;
  // 关闭 加载动画
  if (requestNum === 0) loadingInstance?.close();
}


</script>
<template>
  <button @click="addLoading">load</button>
  <el-button type="primary" @click="login">登录 login</el-button>
  <el-button type="success" @click="getUsers({pagenum:1,pagesize:2,query:''})">查看用户 users</el-button>
</template>
